package com.itheima.homework1.num4;

import java.util.ArrayList;

public class Test1 {
    public static void main(String[] args) {
        //定义一个集合 存储订单
        ArrayList<ArrayList<ProductItem>> list = new ArrayList<>();
        //定义一个集合 存储订单项
        ArrayList<ProductItem> productItemsList = new ArrayList<>();
        //创建订单项 将对象添加到集合list1
        productItemsList.add(new ProductItem("100823178123","机械键盘",317.97));
        productItemsList.add(new ProductItem("100149628134","益生菌漱口水",157.97));
        productItemsList.add(new ProductItem("98726952160","金士顿u盘",118.95));
        productItemsList.add(new ProductItem("98256524137","小米蓝牙项圈耳机",298.97));
        System.out.println(productItemsList);


        //创建第二个订单项
        ArrayList<ProductItem> productItemsList2 = new ArrayList<>();
        productItemsList2.add(new ProductItem("100823178123","机械键盘",317.97));
        productItemsList2.add(new ProductItem("100149628134","益生菌漱口水",157.97));
        //将每一个订单 存放到存储订单的集合
        list.add(productItemsList);
        list.add(productItemsList2);
        //遍历订单集合 获取每一个订单
        for (int i = 0; i < list.size(); i++) {
            ArrayList<ProductItem> list1 = list.get(i);
            //从每一个订单中 获取订单项 输出信息
            for (int j = 0; j < list1.size(); j++) {
                ProductItem productItem = list1.get(j);
                System.out.println(productItem.getId() + " " + productItem.getName() + " " + productItem.getPrice());

            }

        }

    }
}
